package team.seekers.oj.third.controller;

import org.springframework.web.bind.annotation.*;
import team.seekers.oj.common.annotation.UserSession;
import team.seekers.oj.common.entity.ApiResponseBody;
import team.seekers.oj.common.entity.UserSessionDTO;

import static team.seekers.oj.third.utils.TencentYunVedioUtil.*;


/**
 * @Author GodC
 * @Date 2020/6/15 18:24
 */
@RestController
@RequestMapping("/")
public class LiveController {


    /**
     * 生成OBS推流码
     */
    @GetMapping("createOBSPushUrl/{streamName}")
    public  String createPushUrl(@PathVariable String streamName) {
        //过期时间 16进制的unix时间戳
        String txTime = to16Hex(addOneDay());
        // 填写自己的streamName
        StringBuffer sb = new StringBuffer();
        sb.append(streamName).append("?").append("txSecret=")
                .append(genSign(push_key, streamName,txTime)).append("&").append("txTime=")
                .append(txTime);
        return sb.toString();
    }


    /**
     * type:视频类型，web端主要是m3u8
     * streamName：类似于房间名
     */
    @PostMapping("createPlayUrl/{type}/{streamName}")
    public  String createPlayUrl(@PathVariable String type,@PathVariable String streamName) {
        //过期时间 16进制的unix时间戳
        StringBuffer sb = new StringBuffer();
        sb.append("http://laliu.1.116.143.234/live/").append(streamName).append(".").append(type);
        return sb.toString();
    }


}

